﻿<?

	include '../secured/template.php';
	
	$personal["name"]= "Hans Huber";
	$personal["rolle"] = "Projektleiter";
	$personal["gebdatum"] = "12.3.1990";
	$personal["passwort"] = md5("hans");
	//$db->insert("Personal", $personal);
	
	$columns = array();
	$columns[] = "pk_persnr";
	$columns[] = "name";
	$columns[] = "gebdatum";
	$columns[] = "passwort";
	$where = array(
	'pk_persnr'=>1
	);
	
	print_r($where);
	print_r($columns);
	$result = $db->select("Personal", $columns, $where);
	
	echo "<p>";
	foreach($result as $entry) {
		echo 'Persnr: ' . $entry['pk_persnr'] . 'Name: ' . $entry['name'] . ' Passwort: ' . $entry['passwort'] . '  GD: ' . $entry['gebdatum'] . "<br/>";
	}
	echo "</p>";

	//SELECT name FROM sqlite_master WHERE type='table' ORDER BY name
	
	$az["von"]="20.6.2012 08:00";
	$az["bis"]="20.6.2012 15:00";
	$db->insert("Arbeitszeit", $az);
	
	$columns = array();
	$columns[] = "pk_id";
	$columns[] = "von";
	$columns[] = "bis";
	$result = $db->select("Arbeitszeit", $columns);
	
	echo "<p>";
	foreach($result as $entry) {
		echo 'ID: ' . $entry['pk_id'] . 'Von: ' . $entry['von'] . '  Bis: ' . $entry['bis'] . "<br/>";
	}
	echo "</p>";
	
	$projekt["name"]= "TestProjekt";
	$projekt["deadline"] = "31.07.2012";
	$projekt["budget"] = "9999999,99";
	$db->insert("Projekt", $projekt);
	
	$columns = array();
	$columns[] = "pk_nr";
	$columns[] = "name";
	$columns[] = "deadline";
	$columns[] = "budget";
	$result = $db->select("Projekt", $columns);
	echo "<p>";
	foreach($result as $entry) {
		echo 'ID: ' . $entry['pk_nr'] . 'Name: ' . $entry['name'] . '  deadline: ' . $entry['deadline'] . '  budget: ' . $entry['budget'] . "<br/>";
	}
	echo "</p>";
	
	$arbeitet["fk_personal"]=1;
	$arbeitet["fk_arbeitszeit"]=1;
	$arbeitet["fk_projekt"]=1;
	
	$db->insert("Arbeitet", $arbeitet);
	
	$columns = array();
	$columns[] = "fk_personal";
	$columns[] = "fk_arbeitszeit";
	$columns[] = "fk_projekt";
	$result = $db->select("Arbeitet", $columns);
	echo "<p>";
	foreach($result as $entry) {
		echo 'persNr: ' . $entry['fk_personal'] . ' aid: ' . $entry['fk_arbeitszeit'] . '  pid: ' . $entry['fk_projekt'] . "<br/>";
	}
	echo "</p>";
	
	$termin["text"]="Zwischenmeeting";
	$termin["uhrzeit"]="12:00";
	$termin["datum"]="20.06.2012";
	$termin["ort"]="Kapfenberg";
	$termin["fk_projekt"]=1;
	$db->insert("Termin", $termin);
	
	$columns = array();
	$columns[] = "text";
	$columns[] = "uhrzeit";
	$columns[] = "datum";
	$columns[] = "ort";
	$result = $db->select("Termin", $columns);
	echo "<p>";
	foreach($result as $entry) {
		echo 'Text: ' . $entry['text'] . ' datum: ' . $entry['datum'] . '  uhrzeit: ' . $entry['uhrzeit']. '  ort: ' . $entry['ort'] . "<br/>";
	}
	echo "</p>";